<template>
    <div class="not-found-container">
        <!-- 宇航员动图 -->
        <img src="../assets/img/astronaut.gif" alt="Astronaut" class="astronaut" />
        <h1>哎呀！你好像迷失在宇宙中啦 🚀</h1>
        <p>你访问的页面就像一颗神秘的流星，暂时找不到踪迹。别担心，不妨返回主页重新开启探索之旅。</p>
        <router-link to="/" class="home-button">返回主页 🌌</router-link>
        <div class="stars">
            <div 
                class="star" 
                v-for="(star, index) in starsArray" 
                :key="index"
                :style="{ animationDelay: `${getRandomDelay()}s` }"
            ></div>
        </div>
    </div>
</template>

<script setup>
const starsArray = Array.from({ length: 20 }, (_, i) => i);

const getRandomDelay = (max = 3) => {
    return Math.random() * max;
};
</script>

<style scoped>
.not-found-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    width: 100vw;
    background-color: #000;
    color: #fff;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
}

.stars {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.star {
    position: absolute;
    width: 2px;
    height: 2px;
    background-color: white;
    border-radius: 50%;
    animation: star-twinkle 3s ease-in-out infinite;
}

@keyframes star-twinkle {
    0% {
        opacity: 1;
    }
    50% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}

/* 随机分布星星位置 */
.star:nth-child(1) { left: 10%; top: 20%; }
.star:nth-child(2) { left: 30%; top: 40%; }
.star:nth-child(3) { left: 50%; top: 10%; }
.star:nth-child(4) { left: 70%; top: 60%; }
.star:nth-child(5) { left: 90%; top: 30%; }
.star:nth-child(6) { left: 20%; top: 80%; }
.star:nth-child(7) { left: 40%; top: 50%; }
.star:nth-child(8) { left: 60%; top: 70%; }
.star:nth-child(9) { left: 80%; top: 10%; }
.star:nth-child(10) { left: 15%; top: 55%; }
.star:nth-child(11) { left: 35%; top: 75%; }
.star:nth-child(12) { left: 55%; top: 25%; }
.star:nth-child(13) { left: 75%; top: 45%; }
.star:nth-child(14) { left: 95%; top: 65%; }
.star:nth-child(15) { left: 25%; top: 95%; }
.star:nth-child(16) { left: 45%; top: 35%; }
.star:nth-child(17) { left: 65%; top: 55%; }
.star:nth-child(18) { left: 85%; top: 75%; }
.star:nth-child(19) { left: 12%; top: 42%; }
.star:nth-child(20) { left: 32%; top: 62%; }

.astronaut {
    width: 500px;
    height: auto;
    margin-bottom: 30px;
}

h1 {
    font-size: 48px;
    margin-bottom: 20px;
    text-shadow: 0 0 10px #00f, 0 0 20px #00f, 0 0 30px #00f;
}

p {
    font-size: 24px;
    margin-bottom: 40px;
    text-align: center;
    max-width: 600px;
}

.home-button {
    background-color: #00f;
    color: #fff;
    padding: 15px 30px;
    border-radius: 5px;
    text-decoration: none;
    font-size: 20px;
    transition: background-color 0.3s ease;
}

.home-button:hover {
    background-color: #008;
}
</style>